package com.hziee.graduate.ticket.controller;

import com.hziee.graduate.ticket.dto.R;
import com.hziee.graduate.ticket.entity.Tickets;
import com.hziee.graduate.ticket.service.TicketsService;
import org.springframework.web.bind.annotation.*;
import sun.security.krb5.internal.Ticket;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("tickets")
public class TicketsController {
    @Resource
    private TicketsService ticketsService;

    @PostMapping("addTicket")
    public R<Tickets> addTicket(@RequestBody Tickets ticket) {
        return ticketsService.addTicket(ticket);
    }

    @PostMapping("getTicketByOrder")
    public R<List<Ticket>> getTicketByOrder(@RequestBody Map<String, String> map){
        return ticketsService.getTicketByOrder(map.get("orderId"));
    }

    @GetMapping("checkTicket/{ticketId}")
    public R<Object> checkTicket(@PathVariable Long ticketId){
        return ticketsService.checkTicket(ticketId);
    }

    @GetMapping("getTicketStatus/{ticketId}")
    public R<Integer> getTicketStatus(@PathVariable Long ticketId){
        return ticketsService.getTicketStatus(ticketId);
    }

    @PostMapping("removeTicketById")
    public R<Object> removeTicketById(@RequestBody Tickets ticket) {
        return ticketsService.removeTicket(ticket);
    }
}

